package com.own.core.html.tabs;

import org.apache.wicket.extensions.markup.html.tabs.AbstractTab;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;

import com.own.core.html.panel.OwnPanel;
import com.own.core.main.Home;
import com.own.core.object.Dao; 
import com.own.core.object.admin.pages.Page;
import com.own.util.ResourceUtil;

public class OwnAbstractTab extends AbstractTab {

	public OwnAbstractTab(IModel<String> title) {
		super(title);

	}

	Page page;

	public OwnAbstractTab(Page page) {
		
		
		super(ResourceUtil.getResource(page.createClass()));
		this.page = page;
	}

	@Override
	public Panel getPanel(String panelId) {
		
		try {
			if (Dao.class.isAssignableFrom(page.createClass())) {
				return new Home(page);
			}
			return (OwnPanel) page.createClass().newInstance();
		} catch (Exception e) {
			return null;
		}
	}

}
